<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<!DOCTYPE html>
<html lang="zh-CN">
<head>

  <%@ include file="/WEB-INF/include/meta.jsp"%>
  <%@ include file="/WEB-INF/include/css.jsp"%>
  <title>电话资源</title>
  
</head>

<body>

  <%@ include  file="/WEB-INF/include/header.jsp"%>
  
  <%@ include file="/WEB-INF/include/menu.jsp"%>
  
  <div class="container main-content">
  
    <div class="panel panel-default x-panel x-panel-layout">
    
      <div class="panel-heading">
        <ol class="breadcrumb">
          <li><a href="${ctx.host}/user">用户管理</a></li>
          <li class="active">电话资源</li>
        </ol>
      </div>
    
      <div class="panel-body">
      
        <div class="col-xs-2 x-panel-layout-left no-horizontal-padding">
          <%@ include file="/WEB-INF/include/submenu.jsp"%>
        </div>
      
        <div class="col-xs-10 x-panel-layout-right">
          <div class="x-breadcrumb-wrapper">
            <div class="x-breadcrumb clearfix">
              <h2><i class="glyphicon glyphicon-fire"></i>&nbsp;&nbsp;<span>电话资源&nbsp;-&nbsp;资源列表</span></h2>
            </div>
          </div>
          
          <div class="x-breadcrumb-wrapper top-margin-20" style="position: relative;">
            <ul class="nav nav-pills x-breadcrumb-nav">
              <li class="pull-left ${empty period or period eq 'week' ? 'active' : ''}"><a href="${ctx.host}/telephone-resources?date=${day}&period=week">周</a></li>
              <li class="pull-left ${period eq 'month' ? 'active' : ''}"><a href="${ctx.host}/telephone-resources?date=${day}&period=month">月</a></li>
              <li class="pull-left ${period eq 'year' ? 'active' : ''}"><a href="${ctx.host}/telephone-resources?date=${day}&period=year">年</a></li>
              <div class="pull-right" style="margin-left:15px;">
                <input type="text" class="form-control date" name="date" value="${day}" data-validate = "required" placeholder="请选择日期" readOnly/>
              </div>
              <a href="${ctx.host}/telephone-resources/export-view" data-target="#export" data-toggle="modal" class="btn btn-default x-btn btn-shadow btn-shadow-default pull-right">导出</a>
              <a href="${ctx.host}/telephone-resources/create" data-target="#resource-create" data-toggle="modal" class="btn btn-default x-btn btn-shadow btn-shadow-default pull-right">
                <i class="glyphicon glyphicon-plus"></i>&nbsp;&nbsp;添加
              </a>
            </ul>
          </div>
          
          <div class="x-breadcrumb-wrapper top-margin-20" style="position: relative;margin-top: 15px;margin-bottom: 15px;">
            <div class="btn-group pull-left" style="position: relative;margin-bottom: 15px;">
              <a href="${ctx.host}/telephone-resources?period=${period}&date=${day}&experienced=false" class="btn btn-${empty experienced ? 'default' : (!experienced ? 'success' : 'default')} x-btn btn-shadow btn-shadow-${not empty experienced and !experienced ? 'success' : 'default'}">
                &nbsp;&nbsp;未到店
              </a>
            </div>
            
            <div class="btn-group pull-left" style="position: relative;margin-bottom: 15px;">
              <a href="${ctx.host}/telephone-resources?period=${period}&date=${day}&experienced=true" class="btn btn-${(not empty experienced and experienced) ? 'success' : 'default'} x-btn btn-shadow btn-shadow-${experienced ? 'success' : 'default'}">
                &nbsp;&nbsp;已到店
              </a>
            </div>
            
            <span class="pull-right">${begin}&nbsp;&nbsp;至&nbsp;&nbsp;${end}</span>
          </div>
          
          <div class="tab-content">
            <table class="table table-striped table-hover x-table" style="margin-bottom:20px; margin-top: 20px;">
              <thead>
                <tr>
                  <th>姓名</th>
                  <th>性别</th>
                  <th>电话</th>
                  <th>渠道</th>
                  <th>名单收集日期</th>
                  <th>最近一次邀约日期</th>
                  <th>最近一次邀约人</th>
                  <th>预约日期</th>
                  <th>时间</th>
                  <th>是否到店</th>
                  <th>未到店原因</th>
                  <th>是否买课</th>
                  <th>课程数量</th>
                  <th>金额</th>
                  <th class="text-center">操作</th>
                </tr>
              </thead>
              <tbody>
                <c:forEach var="telephoneResource" items="${telephoneResources}">
                  <tr>
                    <td>${telephoneResource.user.name}</td>
                    <td>${telephoneResource.user.userFit.gender.description}</td>
                    <td>${telephoneResource.user.mobile}</td>
                    <td>${telephoneResource.channel}</td>
                    <td><fmt:formatDate value="${telephoneResource.collectDate}" pattern="yyyy-MM-dd"/></td>
                    <td>${telephoneResource.telephoneRecords[0].receptionTime}</td>
                    <td>${telephoneResource.telephoneRecords[0].receptionist.name}</td>
                    <c:set var="courseSchedule" value="${persist.telephoneResource(telephoneResource.user.id)}"></c:set>
                    <td>${courseSchedule.occurDate}</td>
                    <td>${courseSchedule.occurHour}</td>
                    <td>${telephoneResource.experienced ? '是' : '否'}</td>
                    <td>${telephoneResource.experienced ? '' : telephoneResource.breakReason}</td>
                    <td>${telephoneResource.user.ordered ? '是' : '否'}</td>
                    <td>${persist.countRound(telephoneResource.user.id)}</td>
                    <td>${persist.sumPrice(telephoneResource.user.id)}</td>
                    <td class="text-center">
                      <a href="${ctx.host}/telephone-resources/${telephoneResource.id}">详情</a>
                      <a href="${ctx.host}/telephone-resources/${telephoneResource.id}/edit" title="修改" data-toggle="modal" data-target="#resource-edit">修改</a>
                      <c:if test="${empty courseSchedule && !telephoneResource.experienced}">
                        <a href="${ctx.host}/telephone-resources/${telephoneResource.id}/add-experience" title="体验" data-toggle="modal" data-target="#add-experience">体验</a>
                      </c:if>
                      <c:if test="${courseSchedule.scheduleStatus.ready}">
                        <a href="${ctx.host}/telephone-resources/${telephoneResource.id}/cancel-experience?courseScheduleId=${courseSchedule.id}" title="体验" data-toggle="modal" data-target="#cancel-experience">取消体验</a>
                      </c:if>
                      <c:if test="${courseSchedule.scheduleStatus.ready || courseSchedule.scheduleStatus.expiry}">
                        <a href="${ctx.host}/telephone-resources/${telephoneResource.id}/edit-experience?courseScheduleId=${courseSchedule.id}" title="体验" data-toggle="modal" data-target="#edit-experience">重排体验</a>
                      </c:if>
                    </td>
                  </tr>
                </c:forEach>
              </tbody>
            </table>
          </div>
          <div class="form-horizontal clearfix">
            <div class="form-group pull-left" style="width: 60%">
              <label class="control-label col-xs-3">查询总计：</label>
              <div class="col-xs-4" style="padding-left: 0px;">
                <p class="form-control-static">${total}条记录</p>
              </div>
            </div>
              
            <jsp:include page="/WEB-INF/include/page.jsp">
              <jsp:param name="url" value="telephone-resources" />
              <jsp:param name="queryString" value="${queryString}" />
            </jsp:include>
            
          </div>
          
        </div>
      </div>
    </div>
  </div>
  
  <%@ include file="/WEB-INF/include/script.jsp"%>
  <d:resource root="${ctx.resource}/build" type="script" src="js/page/user/telephone-resource-list.js">
    <script type="text/javascript">
      require(['page/user/telephone-resource-list'], function(page) {
        page.init({
          "today": '${today}'
        })
      })
    </script>
  </d:resource>
  
</body>
</html>